/*
	common
	Created: 2012-04-19
	sam.huang
*/
var Lang = Lang||{};
(function(){
	Lang.staticPrefix = null;
	
	Lang.init = function (lang){
		if(Lang.staticPrefix == null){
			console.error("[Lang] Please set staticPrefix.");
			return;
		}
		document.write("<script src='"+Lang.staticPrefix+"/biz/js/lang/"+normalize(lang)+".js'></script>");
	};
	
	Lang.setStaticPrefix = function(staticPrefix){
		this.staticPrefix = staticPrefix;
		return this;
	};
	
	//占位符替换
	Lang.placeholderFill = function(str, values){
		return str.replace(/\{(\d+)\}/g, function(m, i) {
			return values[i];
		});
	};
	
	function normalize(lang){
		switch(lang){
		case "zh-cn":
		case "zh_cn":
		case "zh_CN":
		case "zh":
			return "zh-cn";
		case "zh-tw":
		case "zh_tw":
		case "zh_TW":
			return "zh-tw";
		case "en":
		case "en_US":
			return "en";
		case "ja":
			return "ja";
		case "ko-kr":
		case "ko_KR":
		case "ko":
			return "ko-kr";
		default:
			return "zh-cn";
		}
	}
})();

